package com.ruoyi.new2.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.new2.domain.ExArticleNew;
import com.ruoyi.new2.service.IExArticleNewService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 文章新Controller
 * 
 * @author ruoyi
 * @date 2024-04-07
 */
@RestController
@RequestMapping("/new2/new2")
public class ExArticleNewController extends BaseController
{
    @Autowired
    private IExArticleNewService exArticleNewService;

    /**
     * 查询文章新列表
     */
    @PreAuthorize("@ss.hasPermi('new2:new2:list')")
    @GetMapping("/list")
    public TableDataInfo list(ExArticleNew exArticleNew)
    {
        startPage();
        List<ExArticleNew> list = exArticleNewService.selectExArticleNewList(exArticleNew);
        return getDataTable(list);
    }

    /**
     * 导出文章新列表
     */
    @PreAuthorize("@ss.hasPermi('new2:new2:export')")
    @Log(title = "文章新", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, ExArticleNew exArticleNew)
    {
        List<ExArticleNew> list = exArticleNewService.selectExArticleNewList(exArticleNew);
        ExcelUtil<ExArticleNew> util = new ExcelUtil<ExArticleNew>(ExArticleNew.class);
        util.exportExcel(response, list, "文章新数据");
    }

    /**
     * 获取文章新详细信息
     */
    @PreAuthorize("@ss.hasPermi('new2:new2:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(exArticleNewService.selectExArticleNewById(id));
    }

    /**
     * 新增文章新
     */
    @PreAuthorize("@ss.hasPermi('new2:new2:add')")
    @Log(title = "文章新", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody ExArticleNew exArticleNew)
    {
        return toAjax(exArticleNewService.insertExArticleNew(exArticleNew));
    }

    /**
     * 修改文章新
     */
    @PreAuthorize("@ss.hasPermi('new2:new2:edit')")
    @Log(title = "文章新", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody ExArticleNew exArticleNew)
    {
        return toAjax(exArticleNewService.updateExArticleNew(exArticleNew));
    }

    /**
     * 删除文章新
     */
    @PreAuthorize("@ss.hasPermi('new2:new2:remove')")
    @Log(title = "文章新", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(exArticleNewService.deleteExArticleNewByIds(ids));
    }
}
